package tasks.OpportunitiesBaseData.MainView.SiebelTab;
import resources.tasks.OpportunitiesBaseData.MainView.SiebelTab.GeographyVerifierHelper;
import tasks.Brand;
import tasks.LayoutOps.Mapping;
import tasks.LayoutOps.Wrapper;
import tasks.OpportunitiesBaseData.Pattern;

import com.rational.test.ft.*;
import com.rational.test.ft.object.interfaces.*;
import com.rational.test.ft.object.interfaces.SAP.*;
import com.rational.test.ft.object.interfaces.WPF.*;
import com.rational.test.ft.object.interfaces.dojo.*;
import com.rational.test.ft.object.interfaces.siebel.*;
import com.rational.test.ft.object.interfaces.flex.*;
import com.rational.test.ft.object.interfaces.generichtmlsubdomain.*;
import com.rational.test.ft.script.*;
import com.rational.test.ft.value.*;
import com.rational.test.ft.vp.*;
import com.ibm.rational.test.ft.object.interfaces.sapwebportal.*;

import core.ControlsMapping;
import core.exceptions.ResultFailureException;
/**
 * Description   : Functional Test Script
 * @author angel.tsvetkov
 */
public class GeographyVerifier extends GeographyVerifierHelper
{
	public boolean verify(Brand brand)
	{
		boolean result = false;
		
		switch (brand) 
		{
			case STG:
			{
				verifySTG();
			}break;

			case ITS:
			{
				
			}break;
		}
		return result;
	}
	
	public boolean verifySTG()
	{
		Wrapper wrapper = new Wrapper(
	    		new Mapping("Geo", ControlsMapping.ManualUpdateView.ContextualDataArea.opportunityName_staticText),
	    		new Mapping("IMT", ControlsMapping.ManualUpdateView.ContextualDataArea.detailKey_staticText),
	    		new Mapping("Country", ControlsMapping.ManualUpdateView.ContextualDataArea.sellerName_staticText)
	    		);
	    
	    return verifier(wrapper, Brand.STG, "255U-FVJL2D");
	}
	
	private boolean verifier(Wrapper wrapper, Brand brand, String dtlKey)
	{
		boolean result = false;
		String testActions = "";
		    
	    try {
	    	
	    	testActions = "\n Get data from the front end.";
	    	wrapper.wrapFrontEnd();
	    	
	    	testActions += "\n Get data from the database.";
	    	wrapper.wrapDatabase("MainView\\SiebelTab\\Geography.sql", new Pattern("%BRAND%", brand.name()), new Pattern("%OPP_DTL_KEY%", dtlKey));
			
			testActions += "Compare front end data and data from the database.";
			if(wrapper.compare())
			{
				result = true;
			}
		
	    } catch (ResultFailureException e) {
			e.printStackTrace();
			setErrorComment(e.getError());
		}
	    setTaskResult("TASK: Verify Manual Update Contextual Data in the front edd and database for " + brand + " brand.", result, testActions);
	    return result;
	}
}

